#include "machine_failure_process.h"
#include "ui_machine_failure_process.h"
#include "main.h"


machine_failure_process::machine_failure_process(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::machine_failure_process)
{
    ui->setupUi(this);

    if(water_level_failure) ui->water_checkBox->setCheckState(Qt::Checked);
    else  ui->water_checkBox->setCheckState(Qt::Unchecked);
    if(backdoor_canopen) ui->backdoor_canopen_checkBox->setCheckState(Qt::Checked);
    else ui->backdoor_canopen_checkBox->setCheckState(Qt::Unchecked);
    if( door_detection_failure ) ui->door_checkBox->setCheckState(Qt::Checked);
    else ui->door_checkBox->setCheckState(Qt::Unchecked);
}

machine_failure_process::~machine_failure_process()
{
    delete ui;
}

void machine_failure_process::on_water_checkBox_stateChanged(int arg1)
{
    if(arg1==Qt::Checked)  water_level_failure=true;
    else water_level_failure=false;
}

void machine_failure_process::on_backdoor_canopen_checkBox_stateChanged(int arg1)
{
    if(arg1==Qt::Checked)  {door_operation->unlock_back_door(true);backdoor_canopen=true;}
    else    {door_operation->unlock_back_door(false);backdoor_canopen=false;}
}

void machine_failure_process::on_door_checkBox_stateChanged(int arg1)
{
     if(arg1==Qt::Checked)   {door_detection_failure=1;}
     else    {door_detection_failure=0;}
}
